home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10604 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  61 lines

  1. Path: news.sfu.ca!news
  2. From: Eric Kolotyluk <eric@enigma.vcr.esltd.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Initializing an Array of Strings
  5. Date: Fri, 08 Mar 1996 12:15:21 -0800
  6. Organization: Enterprise Solutions Limited
  7. Message-ID: <31409559.1FC6@enigma.vcr.esltd.com>
  8. NNTP-Posting-Host: enigma.vcr.esltd.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.5 sun4m)
  13.  
  14. Please reply to eric@enigma.vcr.esltd.com
  15.  
  16. I thought it would be nice to create an exception class to return
  17. an array of strings with the names of the system services to be
  18. indexed by the errorType, for example:
  19.  
  20. class MyClass
  21. {
  22.     . . .
  23.     class System        // Exception Class for system calls
  24.     {
  25.         public:
  26.  
  27.         enum systemError
  28.         {
  29.             openError        = 0,
  30.             mmapError        = 1,
  31.             statError        = 2,
  32.             fcntlError        = 3,
  33.             truncateError    = 4
  34.         };
  35.  
  36.         systemError    errorType;
  37.         char*        errorName[];
  38.         int         errno;       // errno system variable
  39.         
  40.         System(systemError enumValue, int errorNumber)
  41.         : errorType(enumValue)
  42.         , errorName({ "open", "mmap", "stat", "truncate" })
  43.         , errno(errorNumber)
  44.         { }
  45.     };
  46. };
  47.  
  48. But the (Sun) C++ compiler complains
  49.  
  50.      The type "char*[]" is incomplete.
  51.  
  52. for my definition of errorName, and generally chokes on my attempt
  53. to initialize errorName.
  54.  
  55. Is there something basically wrong with what I'm trying to do?
  56. I just don't see what the problem is with the definition of errorName.
  57. Also, is there a way to initialize something with an array of strings?
  58. -- 
  59. ______________________________
  60. http://enigma.vcr.esltd.com/eric
  61.